﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RCREEE.Library.Entities;

namespace RCREEE.Library
{
    public static partial class DataManager
    {

        #region Public Methdos

        public static DataTable GetOneCountryById(int CountryId, int LanguageCode)
        {
            _Command.CommandText = "SP_GetCountryById";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();
            _Command.Parameters.Add("@CountryId", SqlDbType.Int).Value = CountryId;
            //_Command.Parameters.Add("@LanguageCode", SqlDbType.Int).Value = LanguageCode;

            _Adapter.SelectCommand = _Command;

            _DataSet = new DataSet();
            try
            {
                _Adapter.Fill(_DataSet);
            }
            catch (Exception exc)
            {
                CloseConnection();
            }

            if (_DataSet != null && _DataSet.Tables[0].Rows.Count > 0)
            {
                DataTable dtCounryDetails = new DataTable();

                #region create table columns

                dtCounryDetails.Columns.Add("CountryId", typeof(int));
                dtCounryDetails.Columns.Add("EnglishName", typeof(string));
                dtCounryDetails.Columns.Add("FlagImagePath", typeof(string));

                dtCounryDetails.Columns.Add("EnglishCountryName", typeof(string));
                dtCounryDetails.Columns.Add("EnglishRenewableEnergyContributionRate", typeof(float));
                dtCounryDetails.Columns.Add("EnglishRenewableEnergyContributionRateComment", typeof(string));
                dtCounryDetails.Columns.Add("EnglishEnergyEfficiencyContributionRate", typeof(float));
                dtCounryDetails.Columns.Add("EnglishEnergyEfficiencyContributionRateComment", typeof(string));
                dtCounryDetails.Columns.Add("EnglishCurrency", typeof(string));
                dtCounryDetails.Columns.Add("EnglishCapital", typeof(string));
                dtCounryDetails.Columns.Add("EnglishArea", typeof(string));

                dtCounryDetails.Columns.Add("ArabicCountryName", typeof(string));
                dtCounryDetails.Columns.Add("ArabicRenewableEnergyContributionRate", typeof(float));
                dtCounryDetails.Columns.Add("ArabicRenewableEnergyContributionRateComment", typeof(string));
                dtCounryDetails.Columns.Add("ArabicEnergyEfficiencyContributionRate", typeof(float));
                dtCounryDetails.Columns.Add("ArabicEnergyEfficiencyContributionRateComment", typeof(string));
                dtCounryDetails.Columns.Add("ArabicCurrency", typeof(string));
                dtCounryDetails.Columns.Add("ArabicCapital", typeof(string));
                dtCounryDetails.Columns.Add("ArabicArea", typeof(string));

                dtCounryDetails.Columns.Add("FrenchCountryName", typeof(string));
                dtCounryDetails.Columns.Add("FrenchRenewableEnergyContributionRate", typeof(float));
                dtCounryDetails.Columns.Add("FrenchRenewableEnergyContributionRateComment", typeof(string));
                dtCounryDetails.Columns.Add("FrenchEnergyEfficiencyContributionRate", typeof(float));
                dtCounryDetails.Columns.Add("FrenchEnergyEfficiencyContributionRateComment", typeof(string));
                dtCounryDetails.Columns.Add("FrenchCurrency", typeof(string));
                dtCounryDetails.Columns.Add("FrenchCapital", typeof(string));
                dtCounryDetails.Columns.Add("FrenchArea", typeof(string));

                #endregion

                #region fill table with data
                DataRow dr = dtCounryDetails.NewRow();
                try
                {
                    dr["CountryId"] = Convert.ToInt32(_DataSet.Tables[0].Rows[0]["CountryId"]);
                    dr["EnglishName"] = Convert.ToString(_DataSet.Tables[0].Rows[0]["EnglishName"]);
                    if (_DataSet.Tables[0].Rows[0]["FlagImagePath"] != DBNull.Value)
                        dr["FlagImagePath"] = Convert.ToString(_DataSet.Tables[0].Rows[0]["FlagImagePath"]);

                    // English
                    DataRow[] drLanguageData = _DataSet.Tables[0].Select("LanguageCode = 1033");
                    if (drLanguageData.Length > 0)
                    {
                        dr["EnglishCountryName"] = Convert.ToString(drLanguageData[0]["CountryName"]);
                        if (drLanguageData[0]["RenewableEnergyContributionRate"] != DBNull.Value)
                            dr["EnglishRenewableEnergyContributionRate"] = (float)Convert.ToDouble(drLanguageData[0]["RenewableEnergyContributionRate"]);
                        dr["EnglishRenewableEnergyContributionRateComment"] = Convert.ToString(drLanguageData[0]["RenewableEnergyContributionRateComment"]);
                        if (drLanguageData[0]["EnergyEfficiencyContributionRate"] != DBNull.Value)
                            dr["EnglishEnergyEfficiencyContributionRate"] = (float)Convert.ToDouble(drLanguageData[0]["EnergyEfficiencyContributionRate"]);
                        dr["EnglishEnergyEfficiencyContributionRateComment"] = Convert.ToString(drLanguageData[0]["EnergyEfficiencyContributionRateComment"]);
                        dr["EnglishCurrency"] = Convert.ToString(drLanguageData[0]["Currency"]);

                        //Similarly Adding the [Capital] and [Area]
                        dr["EnglishCapital"] = Convert.ToString(drLanguageData[0]["Capital"]);
                        dr["EnglishArea"] = Convert.ToString(drLanguageData[0]["Area"]);
                    }

                    // French
                    drLanguageData = _DataSet.Tables[0].Select("LanguageCode = 1036");
                    if (drLanguageData.Length > 0)
                    {
                        dr["FrenchCountryName"] = Convert.ToString(drLanguageData[0]["CountryName"]);
                        if (drLanguageData[0]["RenewableEnergyContributionRate"] != DBNull.Value)
                            dr["FrenchRenewableEnergyContributionRate"] = (float)Convert.ToDouble(drLanguageData[0]["RenewableEnergyContributionRate"]);
                        dr["FrenchRenewableEnergyContributionRateComment"] = Convert.ToString(drLanguageData[0]["RenewableEnergyContributionRateComment"]);
                        if (drLanguageData[0]["EnergyEfficiencyContributionRate"] != DBNull.Value)
                            dr["FrenchEnergyEfficiencyContributionRate"] = (float)Convert.ToDouble(drLanguageData[0]["EnergyEfficiencyContributionRate"]);
                        dr["FrenchEnergyEfficiencyContributionRateComment"] = Convert.ToString(drLanguageData[0]["EnergyEfficiencyContributionRateComment"]);
                        dr["FrenchCurrency"] = Convert.ToString(drLanguageData[0]["Currency"]);

                        //Similarly Adding the [Capital] and [Area]
                        dr["FrenchCapital"] = Convert.ToString(drLanguageData[0]["Capital"]);
                        dr["FrenchArea"] = Convert.ToString(drLanguageData[0]["Area"]);
                    }

                    // Arabic
                    drLanguageData = _DataSet.Tables[0].Select("LanguageCode = 1025");
                    if (drLanguageData.Length > 0)
                    {
                        dr["ArabicCountryName"] = Convert.ToString(drLanguageData[0]["CountryName"]);
                        if (drLanguageData[0]["RenewableEnergyContributionRate"] != DBNull.Value)
                            dr["ArabicRenewableEnergyContributionRate"] = (float)Convert.ToDouble(drLanguageData[0]["RenewableEnergyContributionRate"]);
                        dr["ArabicRenewableEnergyContributionRateComment"] = Convert.ToString(drLanguageData[0]["RenewableEnergyContributionRateComment"]);
                        if (drLanguageData[0]["EnergyEfficiencyContributionRate"] != DBNull.Value)
                            dr["ArabicEnergyEfficiencyContributionRate"] = (float)Convert.ToDouble(drLanguageData[0]["EnergyEfficiencyContributionRate"]);
                        dr["ArabicEnergyEfficiencyContributionRateComment"] = Convert.ToString(drLanguageData[0]["EnergyEfficiencyContributionRateComment"]);
                        dr["ArabicCurrency"] = Convert.ToString(drLanguageData[0]["Currency"]);

                        //Similarly Adding the [Capital] and [Area]
                        dr["ArabicCapital"] = Convert.ToString(drLanguageData[0]["Capital"]);
                        dr["ArabicArea"] = Convert.ToString(drLanguageData[0]["Area"]);
                    }
                #endregion
                    dtCounryDetails.Rows.Add(dr);
                }
                catch (Exception exp)
                { }
                return dtCounryDetails;
            }
            else
                return null;
        }

        public static bool UpdateCountry(GeorgeCountry _country)
        {
            _Command.CommandText = "SP_UpdateCountry";
            _Command.CommandType = CommandType.StoredProcedure;

            #region Parameters
            _Command.Parameters.Clear();

            // General parameters
            _Command.Parameters.Add("@CountryId", SqlDbType.Int).Value = _country.CountryId;
            _Command.Parameters.Add("@EnglishName", SqlDbType.NVarChar).Value = _country.EnglishName;
            _Command.Parameters.Add("@FlagImagePath", SqlDbType.NVarChar).Value = _country.FlagImagePath;

            // English parameters
            _Command.Parameters.Add("@EnglishCountryName", SqlDbType.NVarChar).Value = _country.EnglishCountryname;

            if (_country.EnglishRenewableEnergyContributionRate == -1)
                _Command.Parameters.Add("@EnglishRenewableEnergyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@EnglishRenewableEnergyContributionRate", SqlDbType.Float).Value = _country.EnglishRenewableEnergyContributionRate;

            _Command.Parameters.Add("@EnglishRenewableEnergyContributionRateComment", SqlDbType.NVarChar).Value = _country.EnglishRenewableEnergyContributionRateComment;

            if (_country.EnglishEnergyEfficiencyContributionRate == -1)
                _Command.Parameters.Add("@EnglishEnergyEfficiencyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@EnglishEnergyEfficiencyContributionRate", SqlDbType.Float).Value = _country.EnglishEnergyEfficiencyContributionRate;

            _Command.Parameters.Add("@EnglishEnergyEfficiencyContributionRateComment", SqlDbType.NVarChar).Value = _country.EnglishEnergyEfficiencyContributionRateComment;
            _Command.Parameters.Add("@EnglishCurrency", SqlDbType.NVarChar).Value = _country.EnglishCurrency;
            // Similarly Added the [Capital] and [Area]
            _Command.Parameters.Add("@EnglishCapital", SqlDbType.NVarChar).Value = _country.EnglishCapital;
            _Command.Parameters.Add("@EnglishArea", SqlDbType.NVarChar).Value = _country.EnglishArea;
            
            // Arabic parameters
            _Command.Parameters.Add("@ArabicCountryName", SqlDbType.NVarChar).Value = _country.ArabicCountryname;

            if (_country.ArabicRenewableEnergyContributionRate == -1)
                _Command.Parameters.Add("@ArabicRenewableEnergyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@ArabicRenewableEnergyContributionRate", SqlDbType.Float).Value = _country.ArabicRenewableEnergyContributionRate;

            _Command.Parameters.Add("@ArabicRenewableEnergyContributionRateComment", SqlDbType.NVarChar).Value = _country.ArabicRenewableEnergyContributionRateComment;

            if (_country.ArabicEnergyEfficiencyContributionRate == -1)
                _Command.Parameters.Add("@ArabicEnergyEfficiencyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@ArabicEnergyEfficiencyContributionRate", SqlDbType.Float).Value = _country.ArabicEnergyEfficiencyContributionRate;

            _Command.Parameters.Add("@ArabicEnergyEfficiencyContributionRateComment", SqlDbType.NVarChar).Value = _country.ArabicEnergyEfficiencyContributionRateComment;
            _Command.Parameters.Add("@ArabicCurrency", SqlDbType.NVarChar).Value = _country.ArabicCurrency;
            // Similarly Added the [Capital] and [Area]
            _Command.Parameters.Add("@ArabicCapital", SqlDbType.NVarChar).Value = _country.ArabicCapital;
            _Command.Parameters.Add("@ArabicArea", SqlDbType.NVarChar).Value = _country.ArabicArea;

            // French parameters
            _Command.Parameters.Add("@FrenchCountryName", SqlDbType.NVarChar).Value = _country.FrenchCountryname;
            if (_country.FrenchRenewableEnergyContributionRate == -1)
                _Command.Parameters.Add("@FrenchRenewableEnergyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@FrenchRenewableEnergyContributionRate", SqlDbType.Float).Value = _country.FrenchRenewableEnergyContributionRate;
            _Command.Parameters.Add("@FrenchRenewableEnergyContributionRateComment", SqlDbType.NVarChar).Value = _country.FrenchRenewableEnergyContributionRateComment;
            if (_country.FrenchEnergyEfficiencyContributionRate == -1)
                _Command.Parameters.Add("@FrenchEnergyEfficiencyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@FrenchEnergyEfficiencyContributionRate", SqlDbType.Float).Value = _country.FrenchEnergyEfficiencyContributionRate;
            _Command.Parameters.Add("@FrenchEnergyEfficiencyContributionRateComment", SqlDbType.NVarChar).Value = _country.FrenchEnergyEfficiencyContributionRateComment;
            _Command.Parameters.Add("@FrenchCurrency", SqlDbType.NVarChar).Value = _country.FrenchCurrency;
            // Similarly Added the [Capital] and [Area]
            _Command.Parameters.Add("@FrenchCapital", SqlDbType.NVarChar).Value = _country.FrenchCapital;
            _Command.Parameters.Add("@FrenchArea", SqlDbType.NVarChar).Value = _country.FrenchArea;

            #endregion
            try
            {
                // Open Connection
                OpenConnection();

                _Command.ExecuteNonQuery();

                // Close Connection
                CloseConnection();

                return true;

            }
            catch (Exception exp)
            {
                // Close Connection
                CloseConnection();

                return false;
            }
        }

        public static bool InsertCountry(GeorgeCountry _country)
        {
            _Command.CommandText = "SP_InsertCountry";
            _Command.CommandType = CommandType.StoredProcedure;

            #region Parameters
            _Command.Parameters.Clear();

            // General parameters
            _Command.Parameters.Add("@EnglishName", SqlDbType.NVarChar).Value = _country.EnglishName;
            _Command.Parameters.Add("@FlagImagePath", SqlDbType.NVarChar).Value = _country.FlagImagePath;

            // English parameters
            _Command.Parameters.Add("@EnglishCountryName", SqlDbType.NVarChar).Value = _country.EnglishCountryname;

            if (_country.EnglishRenewableEnergyContributionRate == -1)
                _Command.Parameters.Add("@EnglishRenewableEnergyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@EnglishRenewableEnergyContributionRate", SqlDbType.Float).Value = _country.EnglishRenewableEnergyContributionRate;

            _Command.Parameters.Add("@EnglishRenewableEnergyContributionRateComment", SqlDbType.NVarChar).Value = _country.EnglishRenewableEnergyContributionRateComment;

            if (_country.EnglishEnergyEfficiencyContributionRate == -1)
                _Command.Parameters.Add("@EnglishEnergyEfficiencyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@EnglishEnergyEfficiencyContributionRate", SqlDbType.Float).Value = _country.EnglishEnergyEfficiencyContributionRate;

            _Command.Parameters.Add("@EnglishEnergyEfficiencyContributionRateComment", SqlDbType.NVarChar).Value = _country.EnglishEnergyEfficiencyContributionRateComment;
            _Command.Parameters.Add("@EnglishCurrency", SqlDbType.NVarChar).Value = _country.EnglishCurrency;

            // Arabic parameters
            _Command.Parameters.Add("@ArabicCountryName", SqlDbType.NVarChar).Value = _country.ArabicCountryname;

            if (_country.ArabicRenewableEnergyContributionRate == -1)
                _Command.Parameters.Add("@ArabicRenewableEnergyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@ArabicRenewableEnergyContributionRate", SqlDbType.Float).Value = _country.ArabicRenewableEnergyContributionRate;

            _Command.Parameters.Add("@ArabicRenewableEnergyContributionRateComment", SqlDbType.NVarChar).Value = _country.ArabicRenewableEnergyContributionRateComment;

            if (_country.ArabicEnergyEfficiencyContributionRate == -1)
                _Command.Parameters.Add("@ArabicEnergyEfficiencyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@ArabicEnergyEfficiencyContributionRate", SqlDbType.Float).Value = _country.ArabicEnergyEfficiencyContributionRate;

            _Command.Parameters.Add("@ArabicEnergyEfficiencyContributionRateComment", SqlDbType.NVarChar).Value = _country.ArabicEnergyEfficiencyContributionRateComment;
            _Command.Parameters.Add("@ArabicCurrency", SqlDbType.NVarChar).Value = _country.ArabicCurrency;

            // French parameters
            _Command.Parameters.Add("@FrenchCountryName", SqlDbType.NVarChar).Value = _country.FrenchCountryname;
            if (_country.FrenchRenewableEnergyContributionRate == -1)
                _Command.Parameters.Add("@FrenchRenewableEnergyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@FrenchRenewableEnergyContributionRate", SqlDbType.Float).Value = _country.FrenchRenewableEnergyContributionRate;
            _Command.Parameters.Add("@FrenchRenewableEnergyContributionRateComment", SqlDbType.NVarChar).Value = _country.FrenchRenewableEnergyContributionRateComment;
            if (_country.FrenchEnergyEfficiencyContributionRate == -1)
                _Command.Parameters.Add("@FrenchEnergyEfficiencyContributionRate", SqlDbType.Float).Value = DBNull.Value;
            else
                _Command.Parameters.Add("@FrenchEnergyEfficiencyContributionRate", SqlDbType.Float).Value = _country.FrenchEnergyEfficiencyContributionRate;
            _Command.Parameters.Add("@FrenchEnergyEfficiencyContributionRateComment", SqlDbType.NVarChar).Value = _country.FrenchEnergyEfficiencyContributionRateComment;
            _Command.Parameters.Add("@FrenchCurrency", SqlDbType.NVarChar).Value = _country.FrenchCurrency;

            #endregion
            try
            {
                // Open Connection
                OpenConnection();

                _Command.ExecuteNonQuery();

                // Close Connection
                CloseConnection();

                return true;

            }
            catch (Exception exp)
            {
                // Close Connection
                CloseConnection();

                return false;
            }
        }

        public static bool DeleteCountry(int CountryId)
        {
            _Command.CommandText = "usp_DeleteCountry";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();

            _Command.Parameters.Add("@CountryId", SqlDbType.Int).Value = CountryId;

            try
            {
               
                OpenConnection();

                _Command.ExecuteNonQuery();

                CloseConnection();

                return true;

            }
            catch (Exception exp)
            {
                CloseConnection();

                return false;
            }
        }
        public static List<TinyItem> GetContactEntites(int CountryId, int LanguageCode)
        {
            _Command.CommandText = "SP_GetContactEntities";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();

            _Command.Parameters.Add("@CountryId", SqlDbType.Int).Value = CountryId;
            _Command.Parameters.Add("@LanguageCode", SqlDbType.Int).Value = LanguageCode;

            _DataSet = new DataSet();

            _Adapter.SelectCommand = _Command;
            try
            {
                _Adapter.Fill(_DataSet);
            }
            catch (Exception exp)
            {

            }
            if (_DataSet != null && _DataSet.Tables[0].Rows.Count > 0)
            {
                List<TinyItem> _lstEntities = new List<TinyItem>();
                foreach (DataRow dr in _DataSet.Tables[0].Rows)
                {
                    TinyItem _tempItem = new TinyItem(Convert.ToInt32(dr["EntityId"]),Convert.ToString(dr["EntityName"]));
                    _lstEntities.Add(_tempItem);
                }
                return _lstEntities;
            }
            return null;
        }

        public static List<TinyItem> GetProjectEntites(int CountryId, int LanguageCode)
        {
            _Command.CommandText = "SP_GetProjectEntities";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();

            _Command.Parameters.Add("@CountryId", SqlDbType.Int).Value = CountryId;
            _Command.Parameters.Add("@LanguageCode", SqlDbType.Int).Value = LanguageCode;

            _DataSet = new DataSet();

            _Adapter.SelectCommand = _Command;
            try
            {
                _Adapter.Fill(_DataSet);
            }
            catch (Exception exp)
            {

            }
            if (_DataSet != null && _DataSet.Tables[0].Rows.Count > 0)
            {
                List<TinyItem> _lstEntities = new List<TinyItem>();
                foreach (DataRow dr in _DataSet.Tables[0].Rows)
                {
                    TinyItem _tempItem = new TinyItem(Convert.ToInt32(dr["EntityId"]), Convert.ToString(dr["EntityName"]));
                    _lstEntities.Add(_tempItem);
                }
                return _lstEntities;
            }
            return null;
        }

        public static List<TinyItem> GetEntitiesByEntityTypeId(int EntityTypeId, int LanguageCode)
        {
            _Command.CommandText = "SP_GetEntitiesByEntityTypeId";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();
            _Command.Parameters.Add("@LanguageCode", SqlDbType.Int).Value = LanguageCode;
            _Command.Parameters.Add("@EntitiesCategoryId", SqlDbType.Int).Value = 1;
            _Command.Parameters.Add("@EntityTypeID", SqlDbType.Int).Value = EntityTypeId;

            _DataSet = new DataSet();

            _Adapter.SelectCommand = _Command;
            try
            {
                _Adapter.Fill(_DataSet);
            }
            catch (Exception exp)
            {

            }
            if (_DataSet != null && _DataSet.Tables[0].Rows.Count > 0)
            {
                List<TinyItem> _lstEntities = new List<TinyItem>();
                foreach (DataRow dr in _DataSet.Tables[0].Rows)
                {
                    TinyItem _tempItem = new TinyItem(Convert.ToInt32(dr["EntityId"]), Convert.ToString(dr["EntityName"]));
                    _lstEntities.Add(_tempItem);
                }
                return _lstEntities;
            }
            return null;
 
        }

        public static List<string> GetMultiValueItemValues(int CountryId, int EntityId, int LanguageCode)
        {
            _Command.CommandText = "SP_GetMultiValueItemValuesByEntityId";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();

            _Command.Parameters.Add("@LanguageCode", SqlDbType.Int).Value = LanguageCode;
            _Command.Parameters.Add("@CountryId", SqlDbType.Int).Value = CountryId;
            _Command.Parameters.Add("EntityId", SqlDbType.Int).Value = EntityId;

            _DataSet = new DataSet();


            _Adapter.SelectCommand = _Command;
            try
            {
                _Adapter.Fill(_DataSet);
            }
            catch (Exception exp)
            {

            }
            if (_DataSet != null && _DataSet.Tables[0].Rows.Count > 0)
            {
                List<string> _lstValues = new List<string>();
                foreach (DataRow dr in _DataSet.Tables[0].Rows)
                {
                    _lstValues.Add(Convert.ToString(dr["Value"]));
                }
                return _lstValues;
            }
            return null;
 
        }

        public static List<TinyItem> GetEntitiesByEntityTypeIdForDDL(int EntityTypeId, int LanguageCode)
        {
            _Command.CommandText = "SP_GetEntitiesByEntityTypeId";
            _Command.CommandType = CommandType.StoredProcedure;

            _Command.Parameters.Clear();
            _Command.Parameters.Add("@LanguageCode", SqlDbType.Int).Value = LanguageCode;
            _Command.Parameters.Add("@EntitiesCategoryId", SqlDbType.Int).Value = 1;
            _Command.Parameters.Add("@EntityTypeID", SqlDbType.Int).Value = EntityTypeId;

            _DataSet = new DataSet();

            _Adapter.SelectCommand = _Command;
            try
            {
                _Adapter.Fill(_DataSet);
            }
            catch (Exception exp)
            {

            }
            if (_DataSet != null && _DataSet.Tables[0].Rows.Count > 0)
            {
                List<TinyItem> _lstEntities = new List<TinyItem>();
                foreach (DataRow dr in _DataSet.Tables[0].Rows)
                {
                    TinyItem _tempItem = new TinyItem(Convert.ToInt32(dr["EntityId"]), Convert.ToString(dr["EntityName"]));
                    _lstEntities.Add(_tempItem);
                }
                TinyItem emptyItem = new TinyItem(0, "");
                _lstEntities.Insert(0,emptyItem);

                return _lstEntities;
            }
            return null;

        }

        #endregion

        #region Private Methods
        #endregion


    }
}
